package com.sensePlusVR.activity.mine;

import org.xutils.x;
import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;

import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.TextView;

import com.sensePlusVR.base.BaseActivity;
import com.sensePlusVR.main.R;
import com.sensePlusVR.utils.AppManager;
import com.sensePlusVR.utils.Constant;
import com.sensePlusVR.utils.MyLog;
import com.sensePlusVR.utils.MyPageJump;
/**
 * @author: Loren
 * @create: 2016-8-10下午2:42:13
 * @desc: FaqSettingActivity
 */
@ContentView(R.layout.activity_setting_faq)
public class HyperlinkSettingActivity extends BaseActivity {
	
	private  static final String TAG = HyperlinkSettingActivity.class.getSimpleName();
	@ViewInject(R.id.title_bar_title_tv)
	private TextView title_bar_title_tv;
	
	@ViewInject(R.id.faq_wv)
	private WebView faq_wv;
	
	private String fromType;
	@Override
	public void setMyContentView() {
		x.view().inject(this);
	}

	@Override
	public void getIntentData() {
		super.getIntentData();
		fromType = MyPageJump.pageJumpGetString(this, Constant.INTENT_HYPERLINK_KEY);
	}
	
	@Override
	public void initView() {
		super.initView();
		AppManager.getInstance().addActivity(this);
		
		WebSettings settings = faq_wv.getSettings();
		// 支持屏幕缩放
		settings.setSupportZoom(true);
		settings.setBuiltInZoomControls(true);
		// 不显示webview缩放按钮
		settings.setDisplayZoomControls(false);
		// 设置初始显示大小（100为不缩放）
		//faq_wv.setInitialScale(100);
		
		//设置背景色(此处设置透明才能正常显示xml中设置的颜色)
		faq_wv.setBackgroundColor(0x00000000);//透明背景
		
		String title = "";
		String url = "";
		if(fromType.equals(Constant.INTENT_HYPERLINK_FAQ)){
			title = getResources().getString(R.string.setting_faq);
			url = "file:///android_asset/faq.html";
		}
		else if(fromType.equals(Constant.INTENT_HYPERLINK_OURTERMS)){
			title = getResources().getString(R.string.register_terms);
			url = "file:///android_asset/terms.html";
		}else if(fromType.equals(Constant.INTENT_HYPERLINK_PRIVACY_POLICY)){
			title = getResources().getString(R.string.register_privacy_policy);
			url = "file:///android_asset/privacy_policy.html";
		}else if(fromType.equals(Constant.INTENT_HYPERLINK_COMPLIANCE_STATEMENT)){
			title = getResources().getString(R.string.register_compliance_statement);
			url = "file:///android_asset/compliance_statement.html";
		}
		
		MyLog.d(TAG, "fromType : " + fromType + " url : " + url);
		
		title_bar_title_tv.setText(title);
		
		faq_wv.loadUrl(url);
		
	}

	@Event(value = { R.id.title_bar_left_ib })
	private void setViewOnClick(View view) {
		switch (view.getId()) {
		case R.id.title_bar_left_ib:
			AppManager.getInstance().finishActivity(this);
			break;

		default:
			break;
		}
	}

}
